-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an API for TLS 1.3 exporter #4230
Conversation
a7eec2a
to
7d98afd
Compare
0f84bdc
to
5a0559f
Compare
tls/s2n_tls13_secrets.c
Outdated
struct s2n_blob digest = EMPTY_CONTEXT(hmac_alg); | ||
|
||
POSIX_GUARD(s2n_hash_init(&hash, hash_alg)); | ||
POSIX_GUARD(s2n_hash_update(&hash, context, context_length)); | ||
POSIX_GUARD(s2n_hash_digest(&hash, digest.data, digest.size)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, this doesn't look right. EMPTY_CONTEXT isn't equivalent to an zero-inited blob of the right size. It actually has a very specific value that we calculate when s2n is initialized:
s2n-tls/tls/s2n_tls13_secrets.c
Lines 85 to 101 in ab7bfce
S2N_RESULT s2n_tls13_empty_transcripts_init() | |
{ | |
DEFER_CLEANUP(struct s2n_hash_state hash = { 0 }, s2n_hash_free); | |
RESULT_GUARD_POSIX(s2n_hash_new(&hash)); | |
s2n_hash_algorithm hash_alg = S2N_HASH_NONE; | |
for (size_t i = 0; i < s2n_array_len(supported_hmacs); i++) { | |
s2n_hmac_algorithm hmac_alg = supported_hmacs[i]; | |
struct s2n_blob digest = EMPTY_CONTEXT(hmac_alg); | |
RESULT_GUARD_POSIX(s2n_hmac_hash_alg(hmac_alg, &hash_alg)); | |
RESULT_GUARD_POSIX(s2n_hash_init(&hash, hash_alg)); | |
RESULT_GUARD_POSIX(s2n_hash_digest(&hash, digest.data, digest.size)); | |
} | |
return S2N_RESULT_OK; | |
} |
This is another fun consequence of the blob limitations from https://github.com/aws/s2n-tls/pull/4230/files#r1343030637 And apparently EMPTY_CONTEXT needs a scary warning, or we might just want to calculate it repeatedly at runtime to avoid this problem :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the immediate bug, also filed #4233 for follow-up.
59e7f68
to
1d2fe6f
Compare
c470110
to
395a02e
Compare
e169f5a
to
5052273
Compare
This is currently only supported for TLS 1.3 and is standard compliant, using the TLS-Exporter function defined by RFC 8446: https://www.rfc-editor.org/rfc/rfc8446#section-7.5
Head branch was pushed to by a user without write access
5052273
to
e6c57d8
Compare
Description of changes:
This adds a new public API that exposes the
TLS-Exporter
function defined in RFC 8446. This API is used by consumers that wish to use the shared secret established from the TLS 1.3 handshake in order to perform out-of-band operations (e.g., custom protocol). The API does not expose the underlying master exporter secret to callers.Call-outs:
Testing:
How is this change tested (unit tests, fuzz tests, etc.)?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.